﻿using dbe.FoundationLibrary.Core.Win32.Structures;

using System;
using System.Runtime.InteropServices;

namespace dbe.FoundationLibrary.Core.Win32.API
{
    /// <summary>
    /// <c>"msimg32.dll"</c>中的Api
    /// </summary>
    public class MsImg32
    {
        /// <summary>
        /// 实现图像的 alpha 混合。
        /// </summary>
        /// <param name="hdcDest">目标设备上下文句柄</param>
        /// <param name="nXOriginDest">目标区域左上角x坐标</param>
        /// <param name="nYOriginDest">目标区域左上角y坐标</param>
        /// <param name="nWidthDest">目标区域宽</param>
        /// <param name="nHeightDest">目标区域高</param>
        /// <param name="hdcSrc">源设备上下文句柄</param>
        /// <param name="nXOriginSrc">源区域左上角x坐标</param>
        /// <param name="nYOriginSrc">源区域左上角y坐标</param>
        /// <param name="nWidthSrc">源区域宽</param>
        /// <param name="nHeightSrc">源区域高</param>
        /// <param name="blendFunction">alpha混合函数</param>
        /// <returns><see langword="true"/>表示混合成功/<see langword="false"/>表示失败</returns>
        [DllImport("msimg32.dll", SetLastError = true)]
        public static extern bool AlphaBlend(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, _BLENDFUNCTION blendFunction);

        /// <summary>
        /// 填充一个矩形区域，使其具有从一种颜色到另一种颜色的渐变效果。
        /// </summary>
        /// <param name="hdc"></param>
        /// <param name="pVertex"></param>
        /// <param name="nVertex"></param>
        /// <param name="pMesh"></param>
        /// <param name="nMesh"></param>
        /// <param name="ulMode"></param>
        /// <returns></returns>
        [DllImport("msimg32.dll", EntryPoint = "GradientFill")]
        public static extern bool GradientFill(IntPtr hdc, _TRIVERTEX[] pVertex, int nVertex,
       _GRADIENT_RECT[] pMesh, int nMesh, int ulMode);
    }
}